]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Unify compilation for POSIX and ARM
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 28 Apr 2015 16:05:13 +0000 (18:05 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 28 Apr 2015 16:41:30 +0000 (18:41 +0200)
Now, it is not necessary to write different Makefiles for POSIX target.

apps/helloworld/Makefile.inc
apps/rpp-test-suite/Makefile.inc
build/Makefile.lib.inc
build/Makefile.rules [new file with mode: 0644]
build/Makefile.rules.arm [moved from build/Makefile.arm.inc with 81% similarity]
build/Makefile.rules.posix [new file with mode: 0644]
build/posix/Debug/GNUmakefile [new file with mode: 0644]
build/posix/GNUmakefile [deleted file]
build/posix/Release/GNUmakefile [new file with mode: 0644]

index 1aade2c1ee2aace645a77f01066e526a06773fab..cdda41d6569c84899ab1528d74ebf2245f36b9fa 100644 (file)
@@ -2,7 +2,7 @@ makefile_inc_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 
 all: helloworld
 
-include $(makefile_inc_dir)/../../build/Makefile.arm.inc
+include $(makefile_inc_dir)/../../build/Makefile.rules
 
 vpath %.c $(makefile_inc_dir)
 helloworld: main.c $(RPP_LIB_DIR)/rpp-lib.lib
index 4cac0b215ede0dbfa4e16bc0add767e6858c0ace..6e7bf5b00b7d80ef67b89ab89c7caa14570be8e3 100644 (file)
@@ -2,7 +2,7 @@ makefile_inc_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 
 all: rpp-test-suite
 
-include $(makefile_inc_dir)/../../build/Makefile.arm.inc
+include $(makefile_inc_dir)/../../build/Makefile.rules
 
 SOURCES = main.c sci.c ain.c can.c $(SOURCES_$(TARGET))
 SOURCES_posix = eth.c fr.c lin.c
index 9486aacb875dab3745de13ffbcca6099add01537..98bce9474f5503bd971b300502083e9c2b1fade7 100644 (file)
@@ -16,7 +16,7 @@ all:: $(makefile_lib_inc_dir)/../rpp-lib.lib
 
 include ../Makefile.config
 include $(makefile_lib_inc_dir)/../Makefile.var
-include $(makefile_lib_inc_dir)/Makefile.arm.inc
+include $(makefile_lib_inc_dir)/Makefile.rules
 
 rpp_lib_c_OBJS   = $(addsuffix .obj,$(basename $(filter %.c,   $(rpp_lib_SOURCES))))
 rpp_lib_asm_OBJS = $(addsuffix .obj,$(basename $(filter %.asm, $(rpp_lib_SOURCES))))
@@ -33,12 +33,10 @@ $(makefile_lib_inc_dir)/../rpp-lib.lib: rpp-lib.lib
 -include $(rpp_lib_OBJS:%.obj=%.dep)
 
 $(rpp_lib_c_OBJS): %.obj: $(makefile_lib_inc_dir)/../%.c
-       $(call mkdir,$(dir $@))
-       $(CC) $(RPP_CFLAGS) $(RPP_MAKE_CFLAGS) $<
+       $(rpp_c_obj_cmds)
 
 $(rpp_lib_asm_OBJS): %.obj: $(makefile_lib_inc_dir)/../%.asm
-       $(call mkdir,$(dir $@))
-       $(CC) $(RPP_CFLAGS) $(RPP_MAKE_CFLAGS) $<
+       $(rpp_c_obj_cmds)
 
 .PHONY: all clean $(makefile_lib_inc_dir)/../rpp-lib.lib
 
diff --git a/build/Makefile.rules b/build/Makefile.rules
new file mode 100644 (file)
index 0000000..2d509e2
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (C) 2013-2015 Czech Technical University in Prague
+#
+# Authors:
+#     - Michal Sojka <sojkam1@fel.cvut.cz>
+#
+# This document contains proprietary information belonging to Czech
+# Technical University in Prague. Passing on and copying of this
+# document, and communication of its contents is not permitted
+# without prior written authorization.
+#
+# File : Makefile.rules.arm
+#
+# This file is meant to be included by other Makefiles to gain
+# "platform independent" compilation for RPP.
+
+ifeq ($(TARGET),)
+$(error "Makefile.config must be included before this file")
+endif
+
+makefile_rules_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+
+ifeq ($(TARGET),posix)
+include $(makefile_rules_dir)/Makefile.rules.posix
+else
+include $(makefile_rules_dir)/Makefile.rules.arm
+endif
similarity index 81%
rename from build/Makefile.arm.inc
rename to build/Makefile.rules.arm
index f0b06a8161cf9bc0bed4a337bb9f75149375406e..694b5b8f12eaf857e0d7bbd0798552ea1f3b0915 100644 (file)
@@ -8,12 +8,12 @@
 # document, and communication of its contents is not permitted
 # without prior written authorization.
 #
-# File : Makefile.arm.rules
+# File : Makefile.rules.arm
 #
-# This file is meant to be included by Makefiles in build directories
-# for ARM platforms.
+# This file contains variables and rules specific for compilation for
+# ARM platforms.
 
-makefile_arm_inc_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+makefile_rules_arm_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 
 ifeq ($(TARGET_CFLAGS),)
 $(error "Makefile.config must be included before this file")
@@ -33,17 +33,17 @@ endef
 $(error $(msg))
 endif
 
-include $(makefile_arm_inc_dir)/../common.mk
+include $(makefile_rules_arm_dir)/../common.mk
 
 CC=$(ARM_COMPILER_DIR)/bin/armcl
 AR=$(ARM_COMPILER_DIR)/bin/armar
 LD=$(CC)
 
 # Include definition of $(rpp_lib_INCLUDES)
-include $(makefile_arm_inc_dir)/../Makefile.var
+include $(makefile_rules_arm_dir)/../Makefile.var
 
 RPP_CFLAGS = $(TARGET_CFLAGS) --gcc -I$(ARM_COMPILER_DIR)/include      \
-               $(rpp_lib_INCLUDES:%=-I$(makefile_arm_inc_dir)/../%)                    \
+               $(rpp_lib_INCLUDES:%=-I$(makefile_rules_arm_dir)/../%)                  \
                --diag_warning=225 --display_error_number --diag_wrap=off               \
                --gen_func_subsections=on --enum_type=packed
 
@@ -57,7 +57,7 @@ define rpp_c_obj_cmds
 endef
 
 BUILD_DIR ?= Debug
-RPP_LIB_DIR = $(makefile_arm_inc_dir)/$(TARGET)/$(BUILD_DIR)
+RPP_LIB_DIR = $(makefile_rules_arm_dir)/$(TARGET)/$(BUILD_DIR)
 
 RPP_LDFLAGS = \
                --run_linker -m"${@:%=%.map}" $(TARGET_LDFLAGS) --diag_wrap=on  \
diff --git a/build/Makefile.rules.posix b/build/Makefile.rules.posix
new file mode 100644 (file)
index 0000000..1e6b746
--- /dev/null
@@ -0,0 +1,49 @@
+# Copyright (C) 2013-2015 Czech Technical University in Prague
+#
+# Authors:
+#     - Michal Sojka <sojkam1@fel.cvut.cz>
+#
+# This document contains proprietary information belonging to Czech
+# Technical University in Prague. Passing on and copying of this
+# document, and communication of its contents is not permitted
+# without prior written authorization.
+#
+# File : Makefile.rules.posix
+#
+# This file contains variables and rules specific for compilation for
+# POSIX platform.
+
+makefile_rules_posix_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+
+ifeq ($(TARGET_CFLAGS),)
+$(error "Makefile.config must be included before this file")
+endif
+
+include $(makefile_rules_posix_dir)/../common.mk
+
+CC=gcc
+AR=ar
+LD=$(CC)
+
+# Include definition of $(rpp_lib_INCLUDES)
+include $(makefile_rules_posix_dir)/../Makefile.var
+
+RPP_CFLAGS = -c $(rpp_lib_INCLUDES:%=-I$(makefile_rules_posix_dir)/../%) $(TARGET_CFLAGS)
+
+RPP_MAKE_CFLAGS = \
+               -MD -MF $@.dep -MP -MT $@
+
+define rpp_c_obj_cmds
+       $(call mkdir,$(dir $@))
+       $(CC) $(RPP_CFLAGS) $(RPP_MAKE_CFLAGS) -o $@ $<
+endef
+
+BUILD_DIR ?= Debug
+RPP_LIB_DIR = $(makefile_rules_posix_dir1)/$(TARGET)/$(BUILD_DIR)
+
+RPP_LDFLAGS =
+
+RPP_LDLIBS = -l$(RPP_LIB_DIR)/rpp-lib.lib $(TARGET_LDLIBS)
+
+$(RPP_LIB_DIR)/rpp-lib.lib:
+       $(MAKE) -C $(dir $@)
diff --git a/build/posix/Debug/GNUmakefile b/build/posix/Debug/GNUmakefile
new file mode 100644 (file)
index 0000000..6d47e9e
--- /dev/null
@@ -0,0 +1,3 @@
+include ../../Makefile.lib.inc
+
+RPP_CFLAGS += -g -O0
diff --git a/build/posix/GNUmakefile b/build/posix/GNUmakefile
deleted file mode 100644 (file)
index f86acd6..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-include Makefile.config
-include ../../Makefile.var
-
-rpp_lib_CFLAGS = -Wall -g -O0 -I../../apps/rpp-lib_posix/include $(rpp_lib_INCLUDES:%=-I../../%)
-
-rpp_lib_MAKE_CFLAGS = -c -MT $@ -MD -MP -MF "$@.d"
-
-rpp_lib_c_OBJS   = $(addsuffix .o,$(basename $(filter %.c,   $(rpp_lib_SOURCES))))
-rpp_lib_asm_OBJS = $(addsuffix .o,$(basename $(filter %.asm, $(rpp_lib_SOURCES))))
-rpp_lib_OBJS = $(rpp_lib_c_OBJS) $(rpp_lib_asm_OBJS)
-rpp_lib_DEPS = $(rpp_lib_OBJS:%.o=%.d)
-
-all:: rpp-lib.a
-
-rpp-lib.a: $(rpp_lib_OBJS) #../../rpp/TMS570LS313xFlashLnk.cmd
-       $(AR) r $@ $^
-
--include $(rpp_lib_OBJS:%.o=%.d)
-
-$(rpp_lib_c_OBJS): %.o: ../../%.c
-       @mkdir -p $(dir $@)
-       $(CC) $(rpp_lib_CFLAGS) $(rpp_lib_MAKE_CFLAGS) -o $@ $<
-
-$(rpp_lib_asm_OBJS): %.o: ../../%.asm
-       @mkdir -p $(dir $@)
-       $(CC) $(rpp_lib_CFLAGS) $(rpp_lib_MAKE_CFLAGS) -o $@ $<
-
-.PHONY: all clean ../../rpp-lib.a
-
-clean::
-       rm -rf $(rpp_lib_OBJS) $(rpp_lib_DEPS) rpp-lib.a
diff --git a/build/posix/Release/GNUmakefile b/build/posix/Release/GNUmakefile
new file mode 100644 (file)
index 0000000..16367b2
--- /dev/null
@@ -0,0 +1,3 @@
+include ../../Makefile.lib.inc
+
+RPP_CFLAGS += -O2