Skip to content

Commit

Permalink
build: Move common files for handling ASN.1 to common
Browse files Browse the repository at this point in the history
Signed-off-by: Daiki Ueno <[email protected]>
  • Loading branch information
ueno committed Sep 21, 2023
1 parent 79fe36c commit 65f0fcd
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 41 deletions.
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ module_LTLIBRARIES =

bashcomp_DATA =

SUFFIXES += .asn .asn.h
.asn.asn.h:
$(AM_V_GEN)$(ASN1PARSER) -o $@ $<

include common/Makefile.am
include p11-kit/Makefile.am
include fuzz/Makefile.am
Expand Down
18 changes: 18 additions & 0 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,22 @@ common_frob_getprogname_SOURCES = common/frob-getprogname.c
common_frob_getprogname_LDADD = $(common_LIBS)
endif

if WITH_ASN1
libp11_common_la_SOURCES = \
common/asn1.c common/asn1.h \
common/oid.c common/oid.h

common_asn_h = \
common/basic.asn.h \
common/openssl.asn.h \
common/pkix.asn.h

BUILT_SOURCES += $(common_asn_h)

EXTRA_DIST += \
common/basic.asn \
common/openssl.asn \
common/pkix.asn
endif

EXTRA_DIST += common/meson.build
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions common/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,50 @@ libp11_tool = static_library('p11-tool', libp11_tool_sources,
libp11_tool_dep = declare_dependency(link_with: libp11_tool,
dependencies: [libp11_common_dep])

if with_asn1
libp11_asn1_sources = [
'asn1.c',
'oid.c',
]

basic_asn_h = custom_target(
'basic.asn.h',
output: 'basic.asn.h',
input: 'basic.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

pkix_asn_h = custom_target(
'pkix.asn.h',
output: 'pkix.asn.h',
input: 'pkix.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

openssl_asn_h = custom_target(
'openssl.asn.h',
output: 'openssl.asn.h',
input: 'openssl.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

asn_h_dep = declare_dependency(
sources: [basic_asn_h, pkix_asn_h, openssl_asn_h],
)

libp11_asn1 = static_library(
'p11-asn1', libp11_asn1_sources,
gnu_symbol_visibility: 'hidden',
include_directories: configinc,
)

libp11_asn1_dep = declare_dependency(
include_directories: [configinc, commoninc],
link_with: libp11_asn1,
dependencies: [asn_h_dep] + libtasn1_deps,
)
endif

# Tests ----------------------------------------------------------------

if get_option('test')
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ endif
# --------------------------------------------------------------------
# Trust Module

with_asn1 = false
with_trust_module = false
libtasn1_deps = []
libtasn1 = dependency('libtasn1', version: '>= 2.3',
Expand All @@ -407,6 +408,7 @@ if libtasn1.found()
if asn1Parser.found()
conf.set('WITH_ASN1', 1)
libtasn1_deps += libtasn1
with_asn1 = true
with_trust_module = true
endif
endif
Expand Down
18 changes: 0 additions & 18 deletions trust/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ check_LTLIBRARIES += \
$(NULL)

libtrust_data_la_SOURCES = \
trust/asn1.c trust/asn1.h \
trust/oid.c trust/oid.h \
trust/utf8.c trust/utf8.h \
trust/x509.c trust/x509.h \
$(asn_h) \
Expand Down Expand Up @@ -129,22 +127,6 @@ EXTRA_DIST += \
trust/p11-kit-trust.module \
trust/meson.build

SUFFIXES += .asn .asn.h
.asn.asn.h:
$(AM_V_GEN)$(ASN1PARSER) -o $@ $<

asn_h = \
trust/basic.asn.h \
trust/openssl.asn.h \
trust/pkix.asn.h

BUILT_SOURCES += $(asn_h)

EXTRA_DIST += \
trust/basic.asn \
trust/openssl.asn \
trust/pkix.asn

# Tests ----------------------------------------------------------------

trust_CFLAGS = \
Expand Down
25 changes: 2 additions & 23 deletions trust/meson.build
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
libtrust_data_sources = [
'asn1.c',
'oid.c',
'utf8.c',
'x509.c'
]

basic_asn_h = custom_target('basic.asn.h',
output: 'basic.asn.h',
input: 'basic.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'])

pkix_asn_h = custom_target('pkix.asn.h',
output: 'pkix.asn.h',
input: 'pkix.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'])

openssl_asn_h = custom_target('openssl.asn.h',
output: 'openssl.asn.h',
input: 'openssl.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'])

asn_h_dep = declare_dependency(
sources: [basic_asn_h, pkix_asn_h, openssl_asn_h]
)

libtrust_data = static_library('libtrust-data',
libtrust_data_sources,
include_directories: [configinc, commoninc],
dependencies: [asn_h_dep] + libtasn1_deps)
dependencies: [libp11_asn1_dep])

libtrust_sources = [
'builder.c',
Expand All @@ -54,7 +33,7 @@ shared_module('p11-kit-trust',
'module-init.c',
name_prefix: '',
c_args: p11_kit_trust_c_args,
dependencies: [asn_h_dep, libp11_library_dep] + dlopen_deps + libtasn1_deps,
dependencies: [libp11_asn1_dep, libp11_library_dep] + dlopen_deps,
link_args: p11_module_ldflags,
link_depends: [p11_module_symbol_map],
link_with: libtrust_data,
Expand Down

0 comments on commit 65f0fcd

Please sign in to comment.