root / tags / start / Makefile

Revision 2, 2.4 kB (checked in by docwhat, 9 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1### ALL CONFIGURATION SHOULD IN CONFIG.MK, NOT HERE
2include config.mk
3
4### Module directories
5MODULES := $(OSDIR) common
6
7### look for include files in
8###   each of the modules
9CPPFLAGS += $(patsubst %,-I%,$(MODULES))
10CPPFLAGS += $(OS) -DVERSION=$(VERSION)
11
12### extra libraries if required
13LIBS :=
14
15### each module will add to this
16SRC :=
17
18BIN := bin/leocad
19
20### include the description for
21###   each module
22include $(patsubst %,%/module.mk,$(MODULES))
23
24### determine the object files
25OBJ := \
26  $(patsubst %.c,%.o,$(filter %.c,$(SRC))) \
27  $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRC)))
28
29
30### link the program
31.PHONY: all
32
33all: $(BIN)
34
35bin/leocad: $(OBJ) bin
36    $(CC) -o $@ $(OBJ) $(LIBS)
37
38bin:
39    mkdir bin
40
41### include the C/C++ include
42###   dependencies
43include $(OBJ:.o=.d)
44
45### calculate C/C++ include
46###   dependencies
47%.d: %.c
48    ./depend.sh $(CC) $(CFLAGS) $(CPPFLAGS) $< > $@
49    [ -s $@ ] || rm -f $@
50
51%.d: %.cpp
52    ./depend.sh $(CXX) $(CXXFLAGS) $(CPPFLAGS) $< > $@
53    [ -s $@ ] || rm -f $@
54
55
56### Various cleaning functions
57.PHONY: clean veryclean spotless all
58
59clean:
60    find $(MODULES) -name \*.o | xargs rm -f
61
62veryclean: clean
63    find $(MODULES) -name \*.d | xargs rm -f
64    rm -rf bin
65
66spotless: veryclean
67    rm -rf arch
68
69
70### dependency stuff is done automatically, so these do nothing.
71.PHONY: dep depend
72
73
74### Help function
75.PHONY: help
76
77help:
78    @echo   'Possible Targets are:'
79    @echo   '       help (this is it)'
80    @echo   '       all'
81    @echo   '       binary'
82    @echo   '       source'
83    @echo   '       (binary and source can be called as'
84    @echo   '        a -zip or -tgz variants)'
85    @echo   '       clean'
86    @echo   '       veryclean'
87    @echo   '       spotless'
88    @echo
89
90###  Rules to make various packaging
91.PHONY: binary binary-tgz source-zip source-tgz source
92
93arch:
94    mkdir arch
95
96binary: binary-zip binary-tgz
97
98binary-zip: arch/leocad-$(VERSION)-linux.zip
99
100binary-tgz: arch/leocad-$(VERSION)-linux.tgz
101
102source: source-tgz source-zip
103
104source-tgz: arch/leocad-$(VERSION)-src.tgz
105
106source-zip: arch/leocad-$(VERSION)-src.zip
107
108
109
110arch/leocad-$(VERSION)-linux.zip: arch all
111    rm -f $@
112    zip -r $@ bin docs examples
113
114arch/leocad-$(VERSION)-linux.tgz: arch all
115    rm -f $@
116    tar cvzf $@ bin docs examples
117
118arch/leocad-$(VERSION)-src.tgz: arch veryclean
119    rm -f $@
120    ( cd .. ; tar --exclude=leocad/arch/\* -cvzf leocad/$@ leocad )
121
122arch/leocad-$(VERSION)-src.zip: arch veryclean
123    rm -f $@
124    ( cd .. ; zip -r leocad/$@ leocad -x leocad/arch/\* )
Note: See TracBrowser for help on using the browser.