How to add library headers to common scope - c

I have following project structure:
Project
|-include
| |-somedir
| | |-someheader.h
|-src
| |-somedir
| | |-somesource.c
| | |-CMakeLists.txt
| |-main.c
| |-CMakeLists.txt
|-lib
| |-somelib
| | |-include
| | | |-somelibheader.h
| | |-src
| | | |-somelibsource.c
| | | |-CMakeLists.txt
| | |-CMakeLists.txt
| |-CMakeLists.txt
|-CMakeLists.txt
Project/CMakeLists.txt:
cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 11)
project(Project)
list(APPEND INCLUDES ${CMAKE_SOURCE_DIR}/include) # Contains all headers will be add to target
set(LIBRARIES_ROOT ${CMAKE_SOURCE_DIR}/lib)
set(SOURCES_ROOT ${CMAKE_SOURCE_DIR}/src)
add_subdirectory(${LIBRARIES_ROOT})
add_subdirectory(${SOURCES_ROOT})
Project/src/CMakeLists.txt:
add_executable(${CMAKE_PROJECT_NAME} main.c)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${INCLUDES}) # adding headers
target_link_libraries(${CMAKE_PROJECT_NAME} ${LIBRARIES}) # linking libraries
add_subdirectory(somedir)
Project/src/somedir/CMakeLists.txt:
target_sources(${CMAKE_PROJECT_NAME} PRIVATE somesource.c)
Project/lib/CMakeLists.txt:
add_subdirectory(somelib)
Project/lib/somelib/CMakeLists.txt:
add_library(somelib)
target_include_directories(somelib PRIVATE include)
list(APPEND INCLUDES include) # Adding lib headers to be included to target
list(APPEND LIBRARIES somelib) # Adding lib to be linked to target
add_subdirectory(src)
Project/lib/somelib/src/CMakeLists.txt:
target_sources(somelib PRIVATE somelibsource.c)
In main.c project headers are able to be included, like #include <somedir/someheader.h>, but library header doesn't. It requires relative to main.c path, like #include "../lib/somelib/include/somelibheader.h". How to fix it and add library headers to common scope?

Related

How to include .a file in PLatformIO?

When I build my project a static library .a file is created (libtest.a).
How can I use this library in other projects?
Folder structure:
|--lib
| |--test
| | |- test.c
| | |- test.h
|
|- platform.ini
|
|--src
| |- main.c
|
|--.pio
| |--build
| | |--genericSTM32F103RB
| | | |--lib704
| | | | |- libtest.a
Is it possible to use libtest.a in other projects and have the same functions?

Excluding the transitive com.google.http-client:google-http-client:1.42.1 child dependency from included dependencies in Gradle

I'm facing this weird java.lang.NoSuchMethodError in my Groovy project, and I have it pretty much down to that there's some transitive grand-child dependency, that is being included by multiple child dependencies (below is just the compileClasspath):
compileClasspath - Compile classpath for source set 'main'.
+--- com.github.javafaker:javafaker:1.0.2
| +--- org.apache.commons:commons-lang3:3.5
| +--- org.yaml:snakeyaml:1.23
| \--- com.github.mifmif:generex:1.0.2
| \--- dk.brics.automaton:automaton:1.11-8
+--- com.google.apis:google-api-services-gmail:v1-rev20220404-2.0.0
| \--- com.google.api-client:google-api-client:2.0.0
| +--- com.google.oauth-client:google-oauth-client:1.34.1
| | _+--- com.google.http-client:google-http-client:1.42.0 -> 1.42.1_
| | | +--- org.apache.httpcomponents:httpclient:4.5.13
| | | | +--- org.apache.httpcomponents:httpcore:4.4.13 -> 4.4.15
| | | | +--- commons-logging:commons-logging:1.2
| | | | \--- commons-codec:commons-codec:1.11
| | | +--- org.apache.httpcomponents:httpcore:4.4.15
| | | +--- com.google.code.findbugs:jsr305:3.0.2
| | | +--- com.google.guava:guava:30.1.1-android -> 31.1-jre
| | | | +--- com.google.guava:failureaccess:1.0.1
| | | | +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
| | | | +--- com.google.code.findbugs:jsr305:3.0.2
| | | | +--- org.checkerframework:checker-qual:3.12.0
| | | | +--- com.google.errorprone:error_prone_annotations:2.11.0
| | | | \--- com.google.j2objc:j2objc-annotations:1.3
| | | +--- com.google.j2objc:j2objc-annotations:1.3
| | | +--- io.opencensus:opencensus-api:0.31.1
| | | | \--- io.grpc:grpc-context:1.27.2
| | | \--- io.opencensus:opencensus-contrib-http-util:0.31.1
| | | +--- io.opencensus:opencensus-api:0.31.1 (*)
| | | \--- com.google.guava:guava:29.0-android -> 31.1-jre (*)
| | +--- com.google.http-client:google-http-client-gson:1.42.0 -> 1.42.1
| | | _+--- com.google.http-client:google-http-client:1.42.1 (*)_
| | | \--- com.google.code.gson:gson:2.9.0
| | \--- com.google.guava:guava:31.1-android -> 31.1-jre (*)
| +--- com.google.http-client:google-http-client-gson:1.42.1 (*)
| +--- com.google.guava:guava:31.1-jre (*)
| +--- com.google.http-client:google-http-client-apache-v2:1.42.1
| | _+--- com.google.http-client:google-http-client:1.42.1 (*)_
| | +--- org.apache.httpcomponents:httpclient:4.5.13 (*)
| | \--- org.apache.httpcomponents:httpcore:4.4.15
| +--- org.apache.httpcomponents:httpcore:4.4.15
| +--- org.apache.httpcomponents:httpclient:4.5.13 (*)
| \--- _com.google.http-client:google-http-client:1.42.1 (*)_
\--- org.codehaus.groovy:groovy-all:2.4.7
My build.gradle looks like this :
plugins {
id 'java'
id "com.katalon.gradle-plugin" version "0.1.1"
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.github.javafaker:javafaker:1.0.2'
implementation 'com.google.apis:google-api-services-gmail:v1-rev20220404-2.0.0'
}
Notice that there are multiple instances of this com.google.http-client:google-http-client:1.42.1 across different child dependencies!
I try to get rid of those transitive dependencies with:
configurations.all {
exclude group: 'com.google.http-client', module: 'google-http-client'
}
but then my compileClasspath looks like:
compileClasspath - Compile classpath for source set 'main'.
+--- com.github.javafaker:javafaker:1.0.2
| +--- org.apache.commons:commons-lang3:3.5
| +--- org.yaml:snakeyaml:1.23
| \--- com.github.mifmif:generex:1.0.2
| \--- dk.brics.automaton:automaton:1.11-8
+--- com.google.apis:google-api-services-gmail:v1-rev20220404-2.0.0
| \--- com.google.api-client:google-api-client:2.0.0
| +--- com.google.oauth-client:google-oauth-client:1.34.1
| | +--- com.google.http-client:google-http-client-gson:1.42.0 -> 1.42.1
| | | \--- com.google.code.gson:gson:2.9.0
| | \--- com.google.guava:guava:31.1-android -> 31.1-jre
| | +--- com.google.guava:failureaccess:1.0.1
| | +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
| | +--- com.google.code.findbugs:jsr305:3.0.2
| | +--- org.checkerframework:checker-qual:3.12.0
| | +--- com.google.errorprone:error_prone_annotations:2.11.0
| | \--- com.google.j2objc:j2objc-annotations:1.3
| +--- com.google.http-client:google-http-client-gson:1.42.1 (*)
| +--- com.google.guava:guava:31.1-jre (*)
| +--- com.google.http-client:google-http-client-apache-v2:1.42.1
| | +--- org.apache.httpcomponents:httpclient:4.5.13
| | | +--- org.apache.httpcomponents:httpcore:4.4.13 -> 4.4.15
| | | +--- commons-logging:commons-logging:1.2
| | | \--- commons-codec:commons-codec:1.11
| | \--- org.apache.httpcomponents:httpcore:4.4.15
| +--- org.apache.httpcomponents:httpcore:4.4.15
| \--- org.apache.httpcomponents:httpclient:4.5.13 (*)
\--- org.codehaus.groovy:groovy-all:2.4.7
There's NO instances of the com.google.http-client:google-http-client:1.42.1 ANYWHERE! It also doesn't resolve the Error.
java.lang.NoSuchMethodError: com.google.api.client.http.HttpTransport.isMtls()Z
at com.google.api.services.gmail.Gmail$Builder.chooseEndpoint(Gmail.java:11179)
at com.google.api.services.gmail.Gmail$Builder.<init>(Gmail.java:11212)
at com.signaturemd.utils.GmailQuickstart.GetLabels(GmailQuickstart.groovy:72)
at com.signaturemd.utils.GmailQuickstart$GetLabels.call(Unknown Source)
at SMDEmailUtils.run(SMDEmailUtils:6)
What should I do to make sure that only ONE instance of com.google.http-client:google-http-client:1.42.1 is in the project, and that this Error goes away?
When you are saying "multiple instances" of the dependency what do you mean? I would assume you are confused by seeing multiple versions of the same dependency in the dependency graph.
But that has nothing to do with how many physical instances (jar files) will be packed up into the resulting artifact of your own. There is always just one physical instance of any dependency in the resulting artifact managed by either Gradle or Maven. However, if there are multiple different versions of the same dependency in the dependency graph they both choose the most appropriate version of that one physical instance as they see fit:
Gradle
In case of conflict, Gradle by default uses the newest of conflicting versions.
Maven
Dependency mediation - this determines what version of an artifact will be chosen when multiple versions are encountered as dependencies. Maven picks the "nearest definition". That is, it uses the version of the closest dependency to your project in the tree of dependencies. You can always guarantee a version by declaring it explicitly in your project's POM. Note that if two dependency versions are at the same depth in the dependency tree, the first declaration wins.
And you can override that version. So, in case of Gradle, instead of configuration.all { exclude {...} } that excludes the dependency from everywhere you can try configuring the resolutionStrategy like this:
configuration.all {
resolutionStrategy {
force "com.google.http-client:google-http-client:1.42.1"
}
}
That would (snippet from the doc below):
Allows forcing certain versions of dependencies, including transitive dependencies
This is what you need as per your original question. Like obviously, you don't want to exclude the dependency but rather you want to enforce the specific version of it.
For more info you can refer to the official documentation:
https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html#org.gradle.api.artifacts.ResolutionStrategy:force(java.lang.Object[])

Completing the installation of the OpenSSL 3.0.2 FIPS Module

It's very early days yet but I've started migrating from OpenSSL 1.0.2 to 3.0.2. (Windows)
After building OpenSSL 3.0.2, to complete the installation you need to run the 'fipsinstall' command line application.
I did that using this command as suggested:
C:\WORK\c89f702a343c78ef949c71865ebdfc637541b638\bin\openssl.exe fipsinstall -out C:\WORK\c89f702a343c78ef949c71865ebdfc637541b638\fipsmodule.cnf
-module C:\WORK\c89f702a343c78ef949c71865ebdfc637541b638\lib\ossl-modules\fips.dll
HMAC : (Module_Integrity) : Pass SHA1 : (KAT_Digest) : Pass SHA2 :
(KAT_Digest) : Pass SHA3 : (KAT_Digest) : Pass TDES : (KAT_Cipher) :
Pass AES_GCM : (KAT_Cipher) : Pass AES_ECB_Decrypt : (KAT_Cipher) :
Pass RSA : (KAT_Signature) : RNG : (Continuous_RNG_Test) : Pass Pass
ECDSA : (PCT_Signature) : Pass ECDSA : (PCT_Signature) : Pass DSA :
(PCT_Signature) : Pass TLS13_KDF_EXTRACT : (KAT_KDF) : Pass
TLS13_KDF_EXPAND : (KAT_KDF) : Pass TLS12_PRF : (KAT_KDF) : Pass
PBKDF2 : (KAT_KDF) : Pass SSHKDF : (KAT_KDF) : Pass KBKDF : (KAT_KDF)
: Pass HKDF : (KAT_KDF) : Pass SSKDF : (KAT_KDF) : Pass X963KDF :
(KAT_KDF) : Pass X942KDF : (KAT_KDF) : Pass HASH : (DRBG) : Pass CTR :
(DRBG) : Pass HMAC : (DRBG) : Pass DH : (KAT_KA) : Pass ECDH :
(KAT_KA) : Pass RSA_Encrypt : (KAT_AsymmetricCipher) : Pass
RSA_Decrypt : (KAT_AsymmetricCipher) : Pass RSA_Decrypt :
(KAT_AsymmetricCipher) : Pass INSTALL PASSED
which created this config file fipsmodule.cnf
[fips_sect]
activate = 1
install-version = 1
conditional-errors = 1
security-checks = 1
module-mac = 3A:EC:2E:53:3F:92:44:F9:50:13:70:6E:FD:38:37:08:8B:F2:68:56:CC:B4:ED:5F:A1:52:1B:93:15:37:0B:8C
install-mac = 41:9C:38:C2:8F:59:09:43:2C:AA:2F:58:36:2D:D9:04:F9:6C:56:8B:09:E0:18:3A:2E:D6:CC:69:05:04:E1:11
install-status = INSTALL_SELF_TEST_KATS_RUN
However, a cautionary note about OpenSSL 3.0 states:
You must not copy the FIPS module config file output data from one
machine to another.
Here's the layout of the folder containing the files needed to correctly generate the config file.
C:\WORK\c89f702a343c78ef949c71865ebdfc637541b638>tree /f /a
Folder PATH listing
Volume serial number is 448B-63A8
C:.
| conaninfo.txt
| conanmanifest.txt
| fipsmodule.cnf
|
+---bin
| c_rehash.pl
| openssl.exe
|
+---include
| \---openssl
| aes.h
| asn1.h
| asn1err.h
| asn1t.h
| asn1_mac.h
| async.h
| asyncerr.h
| bio.h
| bioerr.h
| blowfish.h
| bn.h
| bnerr.h
| buffer.h
| buffererr.h
| camellia.h
| cast.h
| cmac.h
| cmp.h
| cmperr.h
| cmp_util.h
| cms.h
| cmserr.h
| comp.h
| comperr.h
| conf.h
| conferr.h
| configuration.h
| conftypes.h
| conf_api.h
| core.h
| core_dispatch.h
| core_names.h
| core_object.h
| crmf.h
| crmferr.h
| crypto.h
| cryptoerr.h
| cryptoerr_legacy.h
| ct.h
| cterr.h
| decoder.h
| decodererr.h
| des.h
| dh.h
| dherr.h
| dsa.h
| dsaerr.h
| dtls1.h
| ebcdic.h
| ec.h
| ecdh.h
| ecdsa.h
| ecerr.h
| encoder.h
| encodererr.h
| engine.h
| engineerr.h
| err.h
| ess.h
| esserr.h
| evp.h
| evperr.h
| e_os2.h
| fipskey.h
| fips_names.h
| hmac.h
| http.h
| httperr.h
| idea.h
| kdf.h
| kdferr.h
| lhash.h
| macros.h
| md2.h
| md4.h
| md5.h
| mdc2.h
| modes.h
| objects.h
| objectserr.h
| obj_mac.h
| ocsp.h
| ocsperr.h
| opensslconf.h
| opensslv.h
| ossl_typ.h
| params.h
| param_build.h
| pem.h
| pem2.h
| pemerr.h
| pkcs12.h
| pkcs12err.h
| pkcs7.h
| pkcs7err.h
| proverr.h
| provider.h
| prov_ssl.h
| rand.h
| randerr.h
| rc2.h
| rc4.h
| rc5.h
| ripemd.h
| rsa.h
| rsaerr.h
| safestack.h
| seed.h
| self_test.h
| sha.h
| srp.h
| srtp.h
| ssl.h
| ssl2.h
| ssl3.h
| sslerr.h
| sslerr_legacy.h
| stack.h
| store.h
| storeerr.h
| symhacks.h
| tls1.h
| trace.h
| ts.h
| tserr.h
| txt_db.h
| types.h
| ui.h
| uierr.h
| whrlpool.h
| x509.h
| x509err.h
| x509v3.h
| x509v3err.h
| x509_vfy.h
| __DECC_INCLUDE_EPILOGUE.H
| __DECC_INCLUDE_PROLOGUE.H
|
+---lib
| | libcrypto.lib
| | libssl.lib
| |
| +---cmake
| | conan-official-openssl-variables.cmake
| |
| +---engines-3
| \---ossl-modules
| fips.dll
| legacy.dll
|
\---licenses
| LICENSE.txt
|
\---external
\---perl
\---Text-Template-1.56
LICENSE
Question
As OpenSSL 3.0.2 is deployed to many machines, does it now require distributing the above files too and running the fips install to create a server specific config file? Seems quirky to have all this extra baggage rather than just copying the config file across machines. Why not use the same config (maybe MAC address dependent)? Why is this config needed at all?
OpenSSL 3.0 FIPS module configuration file
Please note that there are two checksums in the configuration file.
One of them is the FIPS module checksum and the other is the checksum
of the configuration. You can copy the file across machines if it is
without the configuration checksum - that means the selftest will be
always run when the FIPS module (i.e., the fips provider) is loaded.
You cannot copy the file if the configuration checksum is present in
it though because that means the selftest won't be run on the machines
where you copy the configuration file to. That would be against the
FIPS implementation guidance that requires to run the selftests at
least once after the installation.
It looks like the openssl.cnf can be copied across machines if it has this defined without install-mac and install-status:
config_diagnostics = 1
openssl_conf = openssl_init
[openssl_init]
providers = provider_sect
[provider_sect]
fips = fips_sect
base = base_sect
[base_sect]
activate = 1
[fips_sect]
activate = 1
install-version = 1
conditional-errors = 1
security-checks = 1
module-mac = 3A:EC:2E:53:3F:92:44:F9:50:13:70:6E:FD:38:37:08:8B:F2:68:56:CC:B4:ED:5F:A1:52:1B:93:15:37:0B:8C
The fipsmodule.cnf has this format:
[fips_sect]
activate = 1
install-version = 1
conditional-errors = 1
security-checks = 1
module-mac = 3A:EC:2E:53:3F:92:44:F9:50:13:70:6E:FD:38:37:08:8B:F2:68:56:CC:B4:ED:5F:A1:52:1B:93:15:37:0B:8C
install-mac = 41:9C:38:C2:8F:59:09:43:2C:AA:2F:58:36:2D:D9:04:F9:6C:56:8B:09:E0:18:3A:2E:D6:CC:69:05:04:E1:11
install-status = INSTALL_SELF_TEST_KATS_RUN

how to write a make file with a project : source in multi-level sub dir , keep obj file in separate folder?

i have a C project , all source file (C and H files)in src directory , have lots of subdirectories
now I want to
1 copy all h files to .\header, without folder struct
2 complier all c files to .\obj, without folder stuct
3 myproject.exe in .\bin
D:\myproject
+---bin
+---header
+---obj
\---src
| main.c
| main.h
|
+---sub1
| | 1.c
| | 1.h
| |
| \---sub11
| | 11.c
| | 11.h
| |
| \---sub111
| 111.c
| 111.h
|
\---sub2
| 2.c
| 2.h
|
\---sub22
| 22.c
| 22.h
|
\---sub221
221.c
221.h
the expected output as follows:
D:.
+---bin
| myproject.exe
|
+---header
| 1.h
| 11.h
| 111.h
| 2.h
| 22.h
| 221.h
| main.h
|
+---obj
| 1.o
| 11.o
| 111.o
| 2.o
| 22.o
| 221.o
| main.o
|
\---src
| main.c
|
+---sub1
| | 1.c
| | 1.h
| |
| \---sub11
| | 11.c
| | 11.h
| |
| \---sub111
| 111.c
| 111.h
|
\---sub2
| 2.c
| 2.h
|
\---sub22
| 22.c
| 22.h
|
\---sub221
221.c
221.h
the follows posts give a good reference , but this post can not support if the source in multiple directory , all obj files is in the same directory as c file
Makefile : Automatically compile all c files, keeping .o files in separate folder
How can I create a Makefile for C projects with SRC, OBJ, and BIN subdirectories?
can any give some example makefile?
First we construct a list of the sources in the tree:
SRCDIR := src
SOURCES := $(shell find $(SRCDIR) -name "*.c")
Then use that to construct a list of the object files we want:
OBJDIR := obj
OBJECTS := $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SOURCES)))
If all the source files were in the working directory, we could use a simple static pattern rule:
$(OBJECTS): $(OBJDIR)/%.o: %.c
blah blah building $# from $<
And to get that to work when the sources are in different directories, all we need is the vpath directive:
SRCDIRS := $(dir $(SOURCES))
vpath %.c $(SRCDIRS)
Now for the headers. To steer the compiler toward the directories containing the headers, we could construct a string of -I flags in one line or we could copy all of the headers into header/ as follows.
To keep all of the headers up to date, and not copy them unnecessarily, we must treat them as targets. First we make a list of them, as we did with the objects:
HEADERS := $(shell find $(SRCDIR) -name "*.h")
HEADERDIR := header
HEADERTARGS := $(addprefix $(HEADERDIR)/,$(notdir $(HEADERS)))
Then we write a static pattern rule, just as we did for the objects:
$(HEADERTARGS): $(HEADERDIR)/%.h: %.h
cp $< $#
vpath %.h $(SRCDIRS)
And finally add the headers as prerequisites of the objects:
$(OBJECTS): $(OBJDIR)/%.o: %.c $(HEADERTARGS)
...
This is slightly inefficient, as it will rebuild all objects if even one header has changed, but to correct that shortcoming would require a more complex makefile.
You want to put a Makefile in each subdirectory where you want to compile some source. And put a Makefile in your project root directory. In your root Makefile, do this:
ALL : make1 make2 ... maken mv_obj
make1 :; make -C src/sub1
...
mv_obj :; mv `find . -name "*.o"` obj/
Alternatively, you can specify where to save your .o file in each Makefile in your subdirectory. E.g.
gcc -o ../../obj/foo.o 1.c

makefile prerequisites rebuild failed when using .d-dependencies-file

As pleased i recreated this Question to give my actual example:
My Problem is, when httpd-fsdata-erw.h is missing at the very first build the rule httpd-fsdata-erw.h:: creates it for me and erverything works fine.
If i touch httpd-fsdata-erw.h make recognised it and is building sourcefile1.o, sourcefile2.o and everything else neede again. Wonderful!
But when i delete httpd-fsdata-erw.h it. Make is checking the prerequisites and does nothing because it said "nothing to be done" although httpd-fsdata-erw.h is missing.
Now when i touch sourcefile2.h make can't find a rule to make target httpd-fsdata-erw.h.
MAYBE i mixed up some error-messages
I can fix it with the .PONY:-target, but as you know every turn it will rebuild most of the stuff.
File-Overview:
extension
|
|-- Makefile
|--(httpd-fsdata-erw.h) (created by perl
|--(httpd-fsdata-erw.c) (created by perl)
|--(httpd-fsdata-erw.o)
|-- ext.o
|-- ext.bin
TOPDIR-- Makefile
|-- obj_dir
| |--sourcefile1.o
| |--sourcefile1.d
| |--sourcefile2.o
| |--sourcefile2.d
| |--...
|
|-- app
| |
| |--sourcefile1.c (needs httpd-fsdata-erw.h)
| |--sourcefile2.c
| |--sourcefile2.h (needs httpd-fsdata-erw.h)
| |--sourcefile3.c
| |--sourcefile4.c
| |
| |--appskt
| | |--webserver
| | | |-- Makefile
| | | |...
| | | |--fsdata
| | | |--index.html
| | | |--somejavascript.js
| | |
| | |
| | |--shell
| | | |...
| | |--crypto
| | | |...
| | |--ftp
| | | |...
| | |
|
|
|-- contiki
| |--Makefile.include
|
|
|
|-- plattform
| |-- cpu
| | |-- Makefile.r7s7210
| | |
| | |
The Makefile in directory=webserver creates with a perl-script httpd-fsdata-erw.h .c and .o to the extension-folder with the rule
HTTPD_FSDATA_ERW_FILES=httpd-fsdata-erw.c httpd-fsdata-erw.h
$(HTTPD_FSDATA_ERW_FILES): $(PATH_WEBSERVER)/index.html $(PATH_WEBSERVER)/somejavascript.js
perl makefsdata -d $(HT....
web_content: $(HTTPD_FSDATA_ERW_FILES)
TOPDIR-- Makefile:
include $(CONTIKI)/Makefile.include
all: project.bin
project.bin: $(somestuff1) $(somestuff2) $(TARGET_PATH)/$(CONTIKI_PROJECT).$(TARGET)
#cmd .... nothing important, just a windows batch-file
|-- contiki--Makefile.include:
-include $(PATH_...)/Makefile.r7s7210
-include ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
$(PROJECT_SOURCEFILES:.c=.d)}
#.PHONY: httpd-fsdata-erw.h
httpd-fsdata-erw.h::
#$(MAKE) -j1 $(EXT_BIN) -C $(EXT_PATH) -f Makefile
$(TARGET_PATH)/%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
some linking stuff
|-- plattform -- cpu -- Makefile.r7s7210:
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR):
...
$(CC) $(CFLAGS) $(IAR_INCLUDES) ... $< --dependencies=n $(#:.o=.d) -o $#)
But when i delete the "missing.h"-file after the very first build, make is unable to find a target.
Is this because of the structure of the .d-file?
It is.
To fix that, use -MP gcc command line switch when generating the .d file:
-MP This option instructs CPP to add a phony target for each dependency
other than the main file, causing each to depend on nothing. These
dummy rules work around errors make gives if you remove header
files without updating the Makefile to match. This is typical output:
test.o: test.c test.h
test.h:

Resources