Skip to content

Commit e33dc34

Browse files
authored
Merge pull request #50 from AdaCore/static-pic-build
Add static-pic build
2 parents 22788f8 + 8bad1c0 commit e33dc34

File tree

2 files changed

+45
-43
lines changed

2 files changed

+45
-43
lines changed

Makefile

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,26 @@ GPRCLEAN = gprclean
6060
# Compute the default library kind, and possibly the other that are to
6161
# be built.
6262

63-
ifeq ($(DEFAULT_LIBRARY_TYPE),static)
64-
ifneq ($(ENABLE_STATIC),true)
65-
$(error static not enabled, cannot be the default)
66-
endif
67-
ifeq ($(ENABLE_SHARED),true)
68-
OTHER_LIBRARY_TYPE := relocatable
69-
endif
70-
else
63+
ifeq ($(DEFAULT_LIBRARY_TYPE),shared)
7164
ifneq ($(ENABLE_SHARED),true)
7265
$(error shared not enabled, cannot be the default)
7366
endif
74-
ifeq ($(ENABLE_STATIC),true)
75-
OTHER_LIBRARY_TYPE := static
67+
endif
68+
69+
ifeq ($(DEFAULT_LIBRARY_TYPE),static)
70+
ifneq ($(ENABLE_STATIC),true)
71+
$(error static not enabled, cannot be the default)
7672
endif
7773
endif
7874

75+
ifeq ($(ENABLE_STATIC), true)
76+
STATIC_LIBRARY=static
77+
endif
78+
79+
ifeq ($(ENABLE_SHARED), true)
80+
LIBRARY_TYPES=$(STATIC_LIBRARY) relocatable static-pic
81+
endif
82+
7983
ifeq ($(DEBUG), true)
8084
PRJ_BUILD := Debug
8185
else
@@ -104,19 +108,18 @@ override GPROPTS += $(foreach v, \
104108

105109
GPR_DEFAULT = -XLIBRARY_TYPE=$(DEFAULT_LIBRARY_TYPE) \
106110
-XXMLADA_BUILD=$(DEFAULT_LIBRARY_TYPE)
107-
GPR_OTHER = -XLIBRARY_TYPE=$(OTHER_LIBRARY_TYPE) \
108-
-XXMLADA_BUILD=$(OTHER_LIBRARY_TYPE)
109111

110-
#######################################################################
111-
# build
112+
#########
113+
# build #
114+
#########
112115

113-
build: tp_xmlada.gpr makefile.setup
114-
$(GPRBUILD) -p $(GPROPTS) $(GPR_DEFAULT) \
115-
--subdirs=$(SDIR)/$(DEFAULT_LIBRARY_TYPE) -Ptemplates_parser
116-
ifneq ($(OTHER_LIBRARY_TYPE),)
117-
$(GPRBUILD) -p $(GPROPTS) $(GPR_OTHER) \
118-
--subdirs=$(SDIR)/$(OTHER_LIBRARY_TYPE) -Ptemplates_parser
119-
endif
116+
build: $(LIBRARY_TYPES:%=build-%) build-tools
117+
118+
build-%: tp_xmlada.gpr makefile.setup
119+
$(GPRBUILD) -p $(GPROPTS) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* \
120+
--subdirs=$(SDIR)/$* -Ptemplates_parser
121+
122+
build-tools:
120123
$(GPRBUILD) -p $(GPROPTS) $(GPR_DEFAULT) \
121124
--subdirs=$(SDIR)/$(DEFAULT_LIBRARY_TYPE) -Ptools/tools
122125

@@ -128,8 +131,9 @@ build-doc: tp_xmlada.gpr makefile.setup
128131
$(MAKE) -C docs $(DOC_FORMATS)
129132
echo Templates_Parser Documentation built with success.
130133

131-
#######################################################################
132-
# setup
134+
#########
135+
# setup #
136+
#########
133137

134138
tp_xmlada.gpr:
135139
ifeq ($(TP_XMLADA), Installed)
@@ -145,10 +149,11 @@ makefile.setup: setup
145149
setup: tp_xmlada.gpr force
146150
printf " $(foreach v,$(ALL_OPTIONS),$(v) = $($(v))\n)" > makefile.setup
147151

148-
#######################################################################
149-
# install
152+
###########
153+
# install #
154+
###########
150155

151-
install-clean:
156+
uninstall:
152157
ifneq (,$(wildcard $(TPREFIX)/share/gpr/manifests/templates_parser))
153158
-$(GPRINSTALL) $(GPROPTS) -f --uninstall \
154159
--prefix=$(TPREFIX) templates_parser
@@ -157,31 +162,28 @@ endif
157162
GPRINST_OPTS=-p -f --prefix=$(TPREFIX) \
158163
--build-var=LIBRARY_TYPE --build-var=TEMPLATES_PARSER_BUILD
159164

160-
install: install-clean
161-
$(GPRINSTALL) $(GPROPTS) $(GPR_DEFAULT) $(GPRINST_OPTS) \
162-
--subdirs=$(SDIR)/$(DEFAULT_LIBRARY_TYPE) \
163-
--build-name=$(DEFAULT_LIBRARY_TYPE) -Ptemplates_parser
164-
ifneq ($(OTHER_LIBRARY_TYPE),)
165-
$(GPRINSTALL) $(GPROPTS) $(GPR_OTHER) $(GPRINST_OPTS) \
166-
--build-name=$(OTHER_LIBRARY_TYPE) \
167-
--subdirs=$(SDIR)/$(OTHER_LIBRARY_TYPE) -Ptemplates_parser
168-
endif
165+
install: uninstall $(LIBRARY_TYPES:%=install-%)
169166
$(GPRINSTALL) $(GPROPTS) $(GPR_DEFAULT) $(GPRINST_OPTS) \
170167
--mode=usage --subdirs=$(SDIR)/$(DEFAULT_LIBRARY_TYPE) \
171168
--install-name=templates_parser -Ptools/tools
172169

173-
#######################################################################
174-
# clean
170+
install-%:
171+
$(GPRINSTALL) $(GPROPTS) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$*\
172+
$(GPRINST_OPTS) --subdirs=$(SDIR)/$* --build-name=$* -Ptemplates_parser
175173

176-
clean:
177-
-$(GPRCLEAN) $(GPR_DEFAULT) $(GPROPTS) -Ptemplates_parser
174+
#########
175+
# clean #
176+
#########
177+
178+
clean: $(LIBRARY_TYPES:%=clean-%)
178179
-$(GPRCLEAN) $(GPR_DEFAULT) $(GPROPTS) -Ptools/tools
179-
ifneq ($(OTHER_LIBRARY_TYPE),)
180-
-$(GPRCLEAN) $(GPR_OTHER) $(GPROPTS) -Ptemplates_parser
181-
endif
182180
$(MAKE) -C docs clean
183181
$(MAKE) -C regtests clean
184182
rm -f auto.cgpr config/setup/auto.cgpr
185183
rm -fr .build makefile.setup
186184
rm -f config/setup/foo.ali config/setup/foo.o tp_xmlada.gpr
187185
rm -f config/setup/foo.ads.std*
186+
187+
clean-%:
188+
-$(GPRCLEAN) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* $(GPROPTS) \
189+
-Ptemplates_parser

tp_shared.gpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ abstract project TP_Shared is
2929
type XMLAda_Type is ("Installed", "Disabled");
3030
XMLAda : XMLAda_Type := external ("TP_XMLADA", "Disabled");
3131

32-
type Library_Kind is ("relocatable", "static");
32+
type Library_Kind is ("relocatable", "static", "static-pic");
3333
Library_Type : Library_Kind := external ("LIBRARY_TYPE", "static");
3434

3535
Processors := external ("PROCESSORS", "0");

0 commit comments

Comments
 (0)