无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Makefile -out-of-source

2023-03-14 17:10 作者:小粉絲8  | 我要投稿

# Makefile for top dir

# $(call makever,1.2.3)

# major.minor.patch

# libtool manual: -version-number

define makever

? @ $(MAKE) -C $@ soname=lib$@.so.$(word 1,$(subst ., ,$(1)))

? @ cp $(OBJDIR)/$@/$@ $(OBJDIR)/$@/lib$@.so.$(1)

? @ cd $(OBJDIR)/$@ ; \

? ? ln -f -s lib$@.so.$(1) lib$@.so.$(word 1,$(subst ., ,$(1))) ; \

? ? cd - >/dev/null 2>&1 ;

? @ cd $(OBJDIR)/$@ ; \

? ? ln -f -s lib$@.so.$(1) lib$@.so ; \

? ? cd - >/dev/null 2>&1 ;

endef

# make # BUILD_DIR=build

ifdef BUILD_DIR

export OBJDIR = $(abspath $(BUILD_DIR))

else

export OBJDIR = $(abspath build)

endif

SUBDIRS = main foo

all : $(SUBDIRS)

install : $(SUBDIRS)

$(SUBDIRS) : | $(OBJDIR)

$(OBJDIR) : ; @ mkdir $@

main : foo

main : ; @ $(MAKE) -C $@

foo : ; $(call makever,1.2.3)

# make DESTDIR=~/foo install

# Alexandre Duret-Lutz's Autotools Tutorial (without animations):

# "is ready to be uncompressed in / on many hosts"

install :

? install -d $(DESTDIR)/usr/local/bin

? install -d $(DESTDIR)/usr/local/lib

? install -m 0755 $(OBJDIR)/main/main $(DESTDIR)/usr/local/bin

? cp -P $(OBJDIR)/foo/*.so* $(DESTDIR)/usr/local/lib

clean :

? @ for dir in $(SUBDIRS); do \

? ? $(MAKE) -C $$dir $@; \

? done

? -rm -fr $(OBJDIR)

.PHONY : $(SUBDIRS) all install clean

---

# Makefile for subdir

# build shared library with -fPIC, -shared

CFLAGS ? ?= # -g -O3 -fPIC # CXXFLAGS for .cpp

CPPFLAGS ?= -MMD -MP -I../foo

LDFLAGS ? = -L$(OBJDIR)/foo # -shared

LDLIBS ? ?= -lfoo

#CC ? ? ? = $(CXX) # link with CXX for .cpp

LDFLAGS ?+= -Wl,-rpath,'$$ORIGIN/../foo'

LDFLAGS ?+= -Wl,-rpath,'$$ORIGIN/../lib'

#LDFLAGS += -Wl,-soname,$(soname)

# make # NDEBUG=1

ifdef NDEBUG

CFLAGS ? += -O3 # .cpp

CPPFLAGS += -DNDEBUG

else

CFLAGS ? += -g # .cpp

LDFLAGS ?+= -fsanitize=address

endif

SUBDIR ? ?= $(OBJDIR)/$(lastword $(subst /, ,$(CURDIR)))

all : $(SUBDIR)/main # $(SUBDIR)/foo

# https://make.mad-scientist.net/papers/how-not-to-use-vpath/

$(SUBDIR)/main : $(addprefix $(SUBDIR)/,$(patsubst %.c,%.o,$(wildcard *.c))) # .cpp

? $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@

$(SUBDIR)/%.o : %.c | $(SUBDIR) # .cpp

? $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<

$(SUBDIR) : ; @ mkdir $@

-include $(SUBDIR)/*.d

clean : ; -rm -fr $(SUBDIR)

.PHONY : all clean

---

# Makefile for subdir

# build shared library with -fPIC, -shared

CFLAGS ? ?= -fPIC # -g -O3 # CXXFLAGS for .cpp

CPPFLAGS ?= -MMD -MP # -I../bar

LDFLAGS ? = -shared # -L$(OBJDIR)/bar

LDLIBS ? ?= # -lbar

#CC ? ? ? = $(CXX) # link with CXX for .cpp

LDFLAGS ?+= -Wl,-rpath,'$$ORIGIN/../bar'

LDFLAGS ?+= -Wl,-rpath,'$$ORIGIN/../lib'

LDFLAGS ?+= -Wl,-soname,$(soname)

# make # NDEBUG=1

ifdef NDEBUG

CFLAGS ? += -O3 # .cpp

CPPFLAGS += -DNDEBUG

else

CFLAGS ? += -g # .cpp

LDFLAGS ?+= -fsanitize=address

endif

SUBDIR ? ?= $(OBJDIR)/$(lastword $(subst /, ,$(CURDIR)))

all : $(SUBDIR)/foo # $(SUBDIR)/bar

# https://make.mad-scientist.net/papers/how-not-to-use-vpath/

$(SUBDIR)/foo : $(addprefix $(SUBDIR)/,$(patsubst %.c,%.o,$(wildcard *.c))) # .cpp

? $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@

$(SUBDIR)/%.o : %.c | $(SUBDIR) # .cpp

? $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<

$(SUBDIR) : ; @ mkdir $@

-include $(SUBDIR)/*.d

clean : ; -rm -fr $(SUBDIR)

.PHONY : all clean

---

#include <stdio.h>

#include <signal.h>

#include <assert.h>

#ifndef NDEBUG

#include <sanitizer/lsan_interface.h>

#endif

#include "foo.h"

void handlerCont(int signum) {

? printf("SIGCONT %d\n", signum);

#ifndef NDEBUG

? __lsan_do_recoverable_leak_check();

#endif

}

int main() {

? signal(SIGCONT, handlerCont); // kill -CONT 123 # pid

? printf("main\n");

? foo();

? int a[1024];

? int n = 10240;

? a[n] = 1; // asan

? assert(0); // -DNDEBUG

}


Makefile -out-of-source的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
逊克县| 来宾市| 晋宁县| 龙州县| 吴忠市| 紫金县| 佛山市| 平舆县| 海口市| 惠东县| 鄢陵县| 南充市| 濮阳县| 黄冈市| 封丘县| 溧阳市| 房山区| 杂多县| 屏山县| 保康县| 杭锦后旗| 沁源县| 青铜峡市| 汕头市| 江山市| 北辰区| 洪雅县| 固阳县| 双柏县| 太白县| 霍邱县| 千阳县| 元江| 菏泽市| 杭锦后旗| 海宁市| 浪卡子县| 阿鲁科尔沁旗| 张家口市| 湛江市| 中西区|