]> git.saurik.com Git - apple/configd.git/blobdiff - SystemConfiguration.fproj/update-headers
configd-801.1.1.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / update-headers
index c1c1104fd1855926aec455ad0e72f9654ee08906..05b247dbd8b11c5783cc98827051769db0fb8234 100755 (executable)
@@ -6,6 +6,8 @@ if (!$ENV{"INSTALL_DIR"} or !$ENV{"PUBLIC_HEADERS_FOLDER_PATH"} or !$ENV{"PRIVAT
 
 $DO_SPLIT = ($#ARGV >= 0 and $ARGV[0] eq "split");
 
+$USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK = $ENV{"USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK"} eq "YES";
+
 $API_BASE = $ENV{"INSTALL_DIR"} . "/" . $ENV{"PUBLIC_HEADERS_FOLDER_PATH"};
 $SPI_BASE = $ENV{"INSTALL_DIR"} . "/" . $ENV{"PRIVATE_HEADERS_FOLDER_PATH"};
 
@@ -42,6 +44,19 @@ sub clean_SPI {
        return $spi_new;
 }
 
+sub create_STUB {
+       my ($api_header) = @_;
+       my ($stub_new);
+
+       $stub_new = "
+#warning \"Please #include <SystemConfiguration/PUBLIC.h> instead of this file directly.\"
+#include <SystemConfiguration/PUBLIC.h>
+";
+       $stub_new =~ s/PUBLIC.h/$api_header/g;
+
+       return $stub_new;
+}
+
 #
 # Update .../PrivateHeaders
 #
@@ -95,7 +110,9 @@ for (@headers) {
        close(API);
 
        $api_new = clean_API($api);
-       if ($api ne $api_new) {
+       next if ($api eq $api_new);     # if no tweaks needed
+
+       if (!$USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK) {
                printf "cleaning .../Headers/%s\n", $api_header;
                open(API, ">", $api_path);
                print API $api_new;
@@ -121,6 +138,29 @@ for (@headers) {
                                close(SPI);
                        }
                }
+       } else {
+               $spi_new = clean_SPI($api);
+               if ($api_new ne $spi_new) {
+                       if ((($stub_header) = ($api =~ /#ifdef\s+USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS\s*.*?\n#include\s+<SystemConfiguration\/(.*?\.h)>\s*.*?\n/))) {
+                               if ($api_header eq $stub_header) {
+                                       die "API & STUB header not unique: $api_header\n";
+                               }
+                       } else {
+                               die "Header missing #ifdef/#else/#endif: $api_header\n";
+                       }
+
+                       printf "updating .../Headers/%s\n", $api_header;
+                       open(API, ">", $api_path);
+                       print API $spi_new;
+                       close(API);
+
+                       printf "  adding .../PrivateHeaders/%s (stub)\n", $stub_header;
+                       $stub_path = $SPI_BASE . "/" . $stub_header;
+                       $stub_new = create_STUB($api_header);
+                       open(STUB, ">", $stub_path);
+                       print STUB $stub_new;
+                       close(STUB);
+               }
        }
 }
 $/ = "\n";