Skip to content

Commit

Permalink
Build with optimizations, static libs, strip
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaehn committed Sep 10, 2021
1 parent d0a7a62 commit 70d8fee
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PKG_CONFIG ?= pkg-config
GUI_LIBS += lv2 x11 cairo sndfile
LV2_LIBS += lv2 sndfile
ifneq ($(shell $(PKG_CONFIG) --exists fontconfig || echo no), no)
GUI_LIBS += fontconfig
GUIPPFLAGS += -DPKG_HAVE_FONTCONFIG
override GUI_LIBS += fontconfig
override GUIPPFLAGS += -DPKG_HAVE_FONTCONFIG
endif

CC ?= gcc
Expand All @@ -18,25 +18,28 @@ STRIP ?= strip
PREFIX ?= /usr/local
LV2DIR ?= $(PREFIX)/lib/lv2

CPPFLAGS += -DPIC
CFLAGS += -std=c99 -fvisibility=hidden -fPIC
CXXFLAGS += -std=c++11 -fvisibility=hidden -fPIC
LDFLAGS += -shared -Wl,-z,relro,-z,now
STRIPFLAGS += -s --strip-program=$(STRIP)
OPTIMIZATIONS ?=-O3 -ffast-math
CFLAGS ?=-Wall
CXXFLAGS ?=-Wall
STRIPFLAGS ?=-s
LDFLAGS ?=-Wl,-Bstatic -Wl,-Bdynamic -Wl,--as-needed

GUIPPFLAGS += -DPUGL_HAVE_CAIRO
override CFLAGS += -std=c99 -fvisibility=hidden -fPIC
override CXXFLAGS += -std=c++11 -fvisibility=hidden -fPIC
override LDFLAGS += -shared -pthread

override GUIPPFLAGS += -DPUGL_HAVE_CAIRO
DSPCFLAGS += `$(PKG_CONFIG) --cflags $(LV2_LIBS)`
GUICFLAGS += `$(PKG_CONFIG) --cflags $(GUI_LIBS)`
DSPLFLAGS += `$(PKG_CONFIG) --libs $(LV2_LIBS)`
GUILFLAGS += `$(PKG_CONFIG) --libs $(GUI_LIBS)`
DSPLIBS += -lm `$(PKG_CONFIG) --libs $(LV2_LIBS)`
GUILIBS += -lm `$(PKG_CONFIG) --libs $(GUI_LIBS)`

ifeq ($(shell test -e src/Locale_$(LANGUAGE).hpp && echo -n yes),yes)
GUIPPFLAGS += -DLOCALEFILE=\"Locale_$(LANGUAGE).hpp\"
override GUIPPFLAGS += -DLOCALEFILE=\"Locale_$(LANGUAGE).hpp\"
endif

ifdef WWW_BROWSER_CMD
GUIPPFLAGS += -DWWW_BROWSER_CMD=\"$(WWW_BROWSER_CMD)\"
override GUIPPFLAGS += -DWWW_BROWSER_CMD=\"$(WWW_BROWSER_CMD)\"
endif

BUNDLE = BJumblr.lv2
Expand Down Expand Up @@ -114,7 +117,8 @@ all: $(BUNDLE)
$(DSP_OBJ): $(DSP_SRC)
@echo -n Build $(BUNDLE) DSP...
@mkdir -p $(BUNDLE)
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(DSPCFLAGS) -Wl,--start-group $(DSPLFLAGS) $< $(DSP_INCL) -Wl,--end-group -o $(BUNDLE)/$@
@$(CXX) $(CPPFLAGS) $(OPTIMIZATIONS) $(CXXFLAGS) $(LDFLAGS) $(DSPCFLAGS) -Wl,--start-group $(DSPLIBS) $< $(DSP_INCL) -Wl,--end-group -o $(BUNDLE)/$@
@$(STRIP) $(STRIPFLAGS) $(BUNDLE)/$@
@echo \ done.

$(GUI_OBJ): $(GUI_SRC)
Expand All @@ -123,7 +127,8 @@ $(GUI_OBJ): $(GUI_SRC)
@mkdir -p $(BUNDLE)/tmp
@cd $(BUNDLE)/tmp; $(CC) $(CPPFLAGS) $(GUIPPFLAGS) $(CFLAGS) $(GUICFLAGS) $(addprefix ../../, $(GUI_C_INCL)) -c
@cd $(BUNDLE)/tmp; $(CXX) $(CPPFLAGS) $(GUIPPFLAGS) $(CXXFLAGS) $(GUICFLAGS) $(addprefix ../../, $< $(GUI_CXX_INCL)) -c
@$(CXX) $(CPPFLAGS) $(GUIPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(GUICFLAGS) -Wl,--start-group $(GUILFLAGS) $(BUNDLE)/tmp/*.o -Wl,--end-group -o $(BUNDLE)/$@
@$(CXX) $(CPPFLAGS) $(GUIPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(GUICFLAGS) -Wl,--start-group $(GUILIBS) $(BUNDLE)/tmp/*.o -Wl,--end-group -o $(BUNDLE)/$@
@$(STRIP) $(STRIPFLAGS) $(BUNDLE)/$@
@rm -rf $(BUNDLE)/tmp
@echo \ done.

Expand All @@ -135,14 +140,6 @@ install:
@cp -R $(BUNDLE) $(DESTDIR)$(LV2DIR)
@echo \ done.

install-strip:
@echo -n "Install (stripped)" $(BUNDLE) to $(DESTDIR)$(LV2DIR)...
@$(INSTALL) -d $(DESTDIR)$(LV2DIR)/$(BUNDLE)
@$(INSTALL_PROGRAM) -m755 $(STRIPFLAGS) $(B_OBJECTS) $(DESTDIR)$(LV2DIR)/$(BUNDLE)
@$(INSTALL_DATA) $(B_FILES) $(DESTDIR)$(LV2DIR)/$(BUNDLE)
@cp -R $(BUNDLE) $(DESTDIR)$(LV2DIR)
@echo \ done.

uninstall:
@echo -n Uninstall $(BUNDLE)...
@rm -f $(addprefix $(DESTDIR)$(LV2DIR)/$(BUNDLE)/, $(FILES))
Expand All @@ -168,6 +165,6 @@ endif
clean:
@rm -rf $(BUNDLE)

.PHONY: all install install-strip uninstall clean
.PHONY: all install uninstall clean

.NOTPARALLEL:

0 comments on commit 70d8fee

Please sign in to comment.