summaryrefslogtreecommitdiff
path: root/web/yacco2/o2linker/makefile_GNU
blob: 12067d8a972b55028d515098cb87ad455f150eab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File: makefile_GNU
# Why:  Creates the o2linker companion to o2 compiler /compiler
# Library placement: 
#   Rlse:   /usr/local/yacco2/bin/o2linker
#   Dbg:    /usr/local/yacco2/bin/o2linker_dbg
#   Genw:   for the pdf file: yacco2/docs
#           for the *.cpp files
#
# How to run: U must choose the label to execute: Rlse, Dbg
#   Rlse --- gen the fast version of library with no debug support
#   Dbg --- gen the debug version of library
#   Genw --- gen the pdf document and the cpp code 
#            from cweb see www.tug.org for details on obtaining code
#            for the literate programming environment aka CWEB
#            and please join Tug. It is a marvalous FOSS
#            Note: U do not need to use Genw as *.cpp and pdf 
#                  document are included in the ``yacco2'' package
#
# Example: gen the debug version of the library
#  cd /usr/local/yacco2/compiler/grammars
#  make Dbg -f Solaris_makefile
#
CC := g++

02_target_dir :=
ifeq ($(MAKECMDGOALS),Rlse)
O2_target_dir := Release 
else
O2_target_dir := Debug
endif

Base_yacco2     := $(O2)
O2_bin      := $(Base_yacco2)/bin
O2_eternals := $(Base_yacco2)/externals
O2_docs     := $(Base_yacco2)/docs
O2_lib      := $(Base_yacco2)/library
O2_lib_grms := $(Base_yacco2)/library/grammars
O2_cc_grms  := $(Base_yacco2)/compiler/grammars
O2_cc       := $(Base_yacco2)/compiler/o2
O2_includes :=  -I'$(O2_cc)' -I'$(O2_cc_grms)' -I'$(O2_lib)' -I'$(O2_lib_grms)'
O2_req_libraries :=   -lyacco2 -lo2grammars 
O2_lib_directories := -L$(O2_cc_grms)/lib/$(O2_target_dir) -L$(O2_lib)/lib/$(O2_target_dir) 

###
# Set up c++ compiler and ld linker options
###
Rlse: Compile_opts :=  -c -O3 -pthread 
Dbg: Compile_opts := -c -g -pthread
Link_opts :=    -Wl,-z -Wl,muldefs -Wl,-Ur #$(O2_lib_directories)
Multi_rd_libs := -static-libgcc -Wl,--start-group -lyacco2 -lo2grammars -Wl,--end-group -lpthread

###
#    Compile, link, and move O2linker into bin account 
###
Rlse: YYY Move_rlse_o2linker 
Dbg: YYY Move_dbg_o2linker 	
YYY:
	$(CC) -v $(Compile_opts) o2linker.cpp -o o2linker.o  $(O2_includes)
	$(CC) -v $(Compile_opts) common_externs.cpp -o common_externs.o $(O2_includes)
	$(CC) -v $(Compile_opts) o2linker_externs.cpp -o o2linker_externs.o $(O2_includes)
	$(CC) -v $(Compile_opts) o2linker_defs.cpp -o o2linker_defs.o $(O2_includes)
	ld '-o' 'o2linker' '-shared-libgcc' '-mtune=generic'\
	--eh-frame-hdr -m elf_i386 --hash-style=both -dynamic-linker\
	/lib/ld-linux.so.2 -o o2linker -z relro /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crt1.o\
	/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.3.2/crtbegin.o\
	-L/usr/lib/gcc/i486-linux-gnu/4.3.2 -L/usr/lib/gcc/i486-linux-gnu/4.3.2\
	-L/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib -L/lib/../lib -L/usr/lib/../lib\
	-L/usr/lib/gcc/i486-linux-gnu/4.3.2/../../..\
	$(O2_lib_directories) o2linker_externs.o o2linker_defs.o common_externs.o o2linker.o\
	--whole-archive -lyacco2 --no-whole-archive  -start-group -lo2grammars  --end-group -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc\
	-lpthread /usr/lib/gcc/i486-linux-gnu/4.3.2/crtend.o\
	/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crtn.o

Move_rlse_o2linker:
	mv o2linker $(O2_bin)
	rm *.o
Move_dbg_o2linker:
	mv o2linker o2linker_dbg
	mv o2linker_dbg $(O2_bin)
	rm o2linker
	rm *.o