# This is a part of PolyORB-HI-C distribution, a minimal # middleware written for generated code from AADL models. # You should use it with the Ocarina toolsuite. CYGPATH_U = @CYGPATH_U@ CYGPATH_W = @CYGPATH_W@ GCC_GENERIC_CFLAGS=-Wall -g all: build-node include $(RUNTIME_PATH)/make/Makefile.$(TARGET) -include ../../userdefined.mk ifneq ($(USE_CPP_LINKER),) LD=$(LD_CPP) endif build-node: compile-node ################################################################################ # Configuration # # In userdefined.mk, we defined the following variables # - USER_CFLAGS : Additional flags to compile .c files # - USER_CPPFLAGS : Additional flags to compile .cpp files # - USER_CC : User overrides CC compiler # - USER_CPP : User ovverides CPP compiler ifneq ($(USER_CC),) CC=$(USER_CC) endif ifneq ($(USER_CPP),) CPP=$(USER_CPP) endif ifneq ($(USER_LD),) LD=$(USER_LD) endif CFLAGS=$(TARGET_CFLAGS) $(USER_CFLAGS) CPPFLAGS=$(CFLAGS) $(USER_CPPFLAGS) LDFLAGS=$(TARGET_LDFLAGS) $(USER_LDFLAGS) ifdef USE_GPROF CFLAGS+=-D__PO_HI_USE_GPROF -pg endif ifeq ($(ENABLE_DYNAMIC_CONFIGURATION),1) CFLAGS+=-D__PO_HI_USE_DYNAMIC_CONFIGURATION endif ifeq ($(NEED_TRANSPORT),yes) CFLAGS+=-D__PO_HI_USE_TRANSPORT endif INCLUDE=-I. -I"${shell $(CYGPATH_W) "${RUNTIME_PATH}/include"}" ifdef TARGET_INCLUDE INCLUDE += $(TARGET_INCLUDE) endif ifdef USER_SOURCES_DIRS INCLUDE+=$(USER_SOURCES_DIRS) endif INCLUDE+=$(USER_INCLUDE) ifndef $(TARGET_NAME) TARGET_NAME=$(TARGET) endif INCLUDE+=-DTARGET=$(TARGET_NAME) ################################################################################ # Files to be compiled ifeq ($(NEED_TRANSPORT), yes) PO_HI_OBJS = \ po_hi_task.o \ po_hi_time.o \ po_hi_protected.o \ po_hi_main.o \ po_hi_messages.o \ po_hi_marshallers.o \ po_hi_giop.o \ po_hi_utils.o \ po_hi_types.o \ po_hi_monitor.o \ po_hi_storage.o \ po_hi_gqueue.o \ drivers/po_hi_driver_exarm.o \ drivers/po_hi_driver_keyboard.o \ drivers/po_hi_driver_exarm_ni_6071e_analog.o \ drivers/po_hi_driver_exarm_ni_6071e_digital.o \ drivers/po_hi_driver_usbbrick_spacewire.o \ drivers/po_hi_driver_linux_serial.o \ drivers/po_hi_driver_leon_serial.o \ drivers/po_hi_driver_leon_eth.o \ drivers/po_hi_driver_serial_common.o \ drivers/po_hi_driver_sockets.o \ drivers/po_hi_driver_rtems_ne2000.o \ drivers/po_hi_driver_rasta_serial.o \ drivers/po_hi_driver_rasta_common.o \ drivers/po_hi_driver_rasta_1553.o \ drivers/po_hi_driver_xc4v_fpga.o \ drivers/po_hi_driver_rasta_1553_brmlib.o \ drivers/po_hi_driver_rasta_spacewire.o \ $(ACTUAL_TRANSPORT) \ po_hi_transport.o $(TARGET_TRANSPORT_SOURCES) GENERATED_OBJS = \ activity.o \ subprograms.o \ types.o \ request.o \ marshallers.o \ deployment.o \ naming.o \ main.o else PO_HI_OBJS = \ po_hi_task.o \ po_hi_time.o \ po_hi_utils.o \ po_hi_protected.o \ po_hi_monitor.o \ po_hi_storage.o \ po_hi_main.o GENERATED_OBJS = \ activity.o \ subprograms.o \ deployment.o \ types.o \ main.o endif ifeq ($(TARGET), $(filter $(TARGET), linux32 linux64 linux32-xenomai-posix linux32-xenomai-native)) PO_HI_OBJS += po_hi_lua.o endif ifeq ($(USE_ASN1_DEPLOYMENT), yes) generate-asn1-deployment: if [ ! -d ../asn-types ]; then mkdir -p ../asn-types ; fi asn1.exe -c -uPER $(ASN_SOURCES) -o ../asn-types for f in real.o asn1crt.o acn.o ber.o xer.o; do \ c_file="`basename $$f .o`.c"; \ $(CC) $(INCLUDE) $(CFLAGS) -c -o $$f ../asn-types/$$c_file || exit 1 ; \ done for f in $(ASN_SOURCES); do \ c_file="`basename $$f .asn`.c"; \ o_file="`basename $$f .asn`.o"; \ if [ -f ../asn-types/$$c_file ]; then $(CC) $(INCLUDE) $(CFLAGS) -c -o $$o_file ../asn-types/$$c_file || exit 1 ; fi \ done GENERATED_OBJS += real.o asn1crt.o xer.o ber.o acn.o $(ASN_OBJS) LDFLAGS += -lm CFLAGS+=-DPO_HI_USE_ASN1 -I../../ -I../asn-types/ else generate-asn1-deployment: endif ################################################################################ # Simulink ifdef SIMULINK_NODE PO_HI_OBJS += po_hi_simulink.o endif ifdef SIMULINK_DIR INCLUDE += -I$(SIMULINK_DIR) \ -I$(SIMULINK_DIRECTORY)/simulink/include \ -I$(SIMULINK_DIRECTORY)/extern/include \ -I$(SIMULINK_DIRECTORY)/rtw/c/src \ -I$(SIMULINK_DIRECTORY)/rtw/c/src/ext_mode/common \ -I$(SIMULINK_DIRECTORY)/rtw/c/libsrc CFLAGS += -DRT -DUSE_RTMODEL -DMODEL=$(SIMULINK_NODE) -DRT -DNUMST=2 -DTID01EQ=1 -DNCSTATES=0 -DUNIX -DMT=0 -DHAVESTDIO LDFLAGS += $(SIMULINK_LDFLAGS) endif ################################################################################ # SCADE ifdef SCADE_DIR INCLUDE += -I$(SCADE_DIR) USER_OBJS += $(SCADE_DIR)/*.o endif ################################################################################ # General LINUXTASTE stuff check-linuxtaste: if [ ! -d $$LINUXTASTE_PATH/output/staging ]; then \ echo "Please define the LINUXTASTE_PATH variable" ; \ echo "It should point to the directory where the distro was built" && exit 2 ; \ fi ################################################################################ # TASTE-RUNTIME-MONITORING ifeq ($(MONITORING), true) MONITORING_OBJS = trace_manager.o remote_configuration.o PO_HI_CPPOBJS += $(MONITORING_OBJS) PO_HI_OBJS += um_threads.o INCLUDE += -I$(RUNTIME_PATH)/src \ -I$(RUNTIME_PATH)/src/monitoring \ -I$(RUNTIME_PATH)/include \ -I$(RUNTIME_PATH)/include/monitoring \ -I$(RUNTIME_PATH)/src/monitoring/cheddar_scheduling CPPFLAGS += -std=c++1y -g @BOOST_CPPFLAGS@ LDFLAGS += -lstdc++ endif hyperperiod-cheddar: python get_cheddar_schedule.py python parser_cheddar_et.py ################################################################################ # General compilation rules compile-po-hi: ifdef SIMULINK_DIR (cd $(SIMULINK_DIR) && $(MAKE) -f $(SIMULINK_NODE).mk && rm -f grt_main.o) endif ifdef SCADE_DIR (cd $(SCADE_DIR) && for v in `ls *.c`; do $(CC) -c $$v; done) endif for f in $(PO_HI_OBJS); do \ c_file="`basename $$f .o`.c"; \ c_file_dirname="`dirname $$f`"; \ if [ -n "$$c_file_dirname" ]; then \ if [ ! -d $$c_file_dirname ]; then mkdir -p $$c_file_dirname ; fi ; \ $(CC) $(INCLUDE) $(CFLAGS) -c -o $$f '$(RUNTIME_PATH)/src/'$$c_file_dirname'/'$$c_file || exit 1 ; \ else \ $(CC) $(INCLUDE) $(CFLAGS) -c -o $$f '$(RUNTIME_PATH)/src/'$$c_file || exit 1 ; \ fi ; \ done for f in $(PO_HI_CPPOBJS); do \ c_file="`basename $$f .o`.cc"; \ c_file_dirname="`dirname $$f`"; \ if [ -n "$$c_file_dirname" ]; then \ if [ ! -d $$c_file_dirname ]; then mkdir -p $$c_file_dirname ; fi ; \ $(CXX) $(INCLUDE) $(CPPFLAGS) -c -o $$f '$(RUNTIME_PATH)/src/'$$c_file_dirname'/'$$c_file || exit 1 ; \ else \ $(CXX) $(INCLUDE) $(CPPFLAGS) -c -o $$f '$(RUNTIME_PATH)/src/'$$c_file || exit 1 ; \ fi ; \ done compile-node: $(BINARY) ifeq ($(TARGET), $(filter $(TARGET), leon3-scoc3 leon.rtems leon.rtems_posix)) OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) $(BINARY): if [ x"$$RTEMS_MAKEFILE_PATH" = x"" ]; then \ echo "Please define the RTEMS_MAKEFILE_PATH variable, exiting" ; \ else \ $(MAKE) generate-asn1-deployment compile-c-files compile-cpp-files compile-ada-files target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) ; \ $(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) $(CFLAGS) ; \ fi endif ifeq ($(TARGET), leon3-xm3) $(BINARY): OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) $(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(make-exe) endif ifeq ($(TARGET), $(filter $(TARGET), x86.rtems x86.rtems_posix)) OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) $(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(make-exe) cp $(BINARY) binary ifeq ($(NEED_TRANSPORT), yes) run: $(BINARY) pidof qemu >/dev/null 2>&1 ; if [ $$? -eq 0 ]; then \ ( sleep 5 ; qemu -net nic,model=ne2k_pci,macaddr=52:54:00:12:34:93 -net socket,connect=127.0.0.1:12345 -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a -serial /dev/stdout ; )& \ echo "Launching QEMU in connect mode" ; \ else \ qemu -net nic,model=ne2k_pci,macaddr=52:54:00:12:34:92 -net socket,listen=:12345 -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a -serial /dev/stdout; \ echo "Launching QEMU in listen mode" ; \ fi else run: $(BINARY) qemu -fda $(RUNTIME_PATH)/utils/x86-rtems-boot.img -hda fat:. -boot a endif #NEED_TRANSPORT endif #TARGET=x86qemu ifeq ($(TARGET), nds.rtems) OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) $(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) endif ifeq ($(TARGET), gumstix.rtems) OBJS = $(USER_OBJS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(EXTERNAL_OBJECTS) $(BINARY): generate-asn1-deployment target-objects check-rtems compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(make-exe) endif ifeq ($(TARGET), compcert) $(BINARY): @if [ ! -f ccomp ]; then \ echo "Compcert not installed, exiting" ; \ else \ $(MAKE) generate-asn1-deployment compile-c-files compile-cpp-files compile-ada-files target-objects compile-po-hi $(GENERATED_OBJS) $(TARGET_OBJECTS); \ for v in $(USER_OBJS); do mv ../../$$v . ; done ; \ mkdir -p drivers; \ for v in $(PO_HI_OBJS); do mv $(RUNTIME_PATH)/src/$$v $$v ; done; \ $(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS); \ fi endif ifeq ($(TARGET), $(filter $(TARGET), native bench linux32 linux64)) EXE=$(BINARY) $(BINARY): $(MAKE) generate-asn1-deployment target-objects compile-c-files compile-cpp-files compile-ada-files compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS) $(LD) -o $(EXE) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(PO_HI_CPPOBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) endif ifeq ($(TARGET), $(filter $(TARGET), win32)) EXE=$(BINARY).exe $(BINARY): @if [ x"$(shell which i686-w64-mingw32-gcc)" = x ]; then \ echo "Windows compiler is not installed in your system, exiting" ; \ else \ $(MAKE) generate-asn1-deployment target-objects compile-c-files compile-ada-files compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS) ; \ $(LD) -o $(EXE) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) ; \ fi endif ifeq ($(TARGET), $(filter $(TARGET), linux32-xenomai-posix linux32-xenomai-native)) EXE=$(BINARY) $(BINARY): @if [ x"$(shell which xeno-config)" = x ]; then \ echo "Xenomai is not installed in your system, exiting" ; \ else \ $(MAKE) generate-asn1-deployment target-objects compile-c-files compile-ada-files compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS) ; \ $(LD) -o $(EXE) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) ; \ fi endif ifeq ($(TARGET), arm.dslinux) $(BINARY): generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS) $(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) endif ifeq ($(TARGET), x86.linuxtaste) $(BINARY): check-linuxtaste generate-asn1-deployment target-objects compile-po-hi $(USER_OBJS) $(GENERATED_OBJS) $(TARGET_OBJECTS) $(CC) -o $(BINARY) $(EXTERNAL_OBJECTS) $(PO_HI_OBJS) $(GENERATED_OBJS) $(USER_OBJS) $(LDFLAGS) endif %.o: %.cpp $(CXX) $(INCLUDE) $(CPPFLAGS) -c -o $@ $< %.o: %.cc $(CXX) $(INCLUDE) $(CPPFLAGS) -c -o $@ $< %.o: %.c $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< clean: target-clean @-rm -f *~ *.o *.al temp.* *.metrix $(BINARY) $(BINARY).bin $(BINARY).bt $(BINARY).num $(BINARY).nxe b~*.* *.ali @-rm -rf drivers if test ! "$(CLEANDIRS)" = ""; then \ rm -rf $(CLEANDIRS); \ fi generate-doc: @if [ -d generated-documentation ]; then rm -rf generated-documentation ; fi @( DOXYBIN=`which doxygen 2>/dev/null` && if [ -x "$$DOXYBIN" ]; then ` which doxygen` doxygen.cfg ; fi ) || exit 0 ifdef USE_GPROF gprof: ./$(BINARY) gprof ./$(BINARY) > gprof.out endif